import React, { Component } from "react";
import { Modal, Radio } from 'antd';
import { statusList } from "../../../fetch/fetchApi";

const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
const StubStatus = {
    "00": "空闲",
    "01": "充电中",
    "02": "故障",
    "03": "车位占用",
    "04": "维护中",
    "05": "离线",
    "06": "在建中",
    "07": "桩程序升级",
    "08": "预约等待充电中",
    "09": "储能车储能中",
    "99": "删除",
    "0B": "插枪空闲",
    "FF": "锁定",
    "-1": "全部",
}
class UpdateStatus extends Component {
    constructor(props) {
        super(props);
    }

    handleStatusChange =(e) => {
        this.props.handle(e.target.value);
    }

    getStatusList = (statusTypeJson, selectedCode) => {
        let radioButtons = [];
        for (let code in statusTypeJson) {
            if (code === selectedCode) {
                radioButtons.push(<RadioButton value={code} checked="true" style={{
                    marginLeft: 10,
                    marginTop: 10
                }}>{statusTypeJson[code]}</RadioButton>);
            } else {
                radioButtons.push(<RadioButton value={code} style={{
                    marginLeft: 10,
                    marginTop: 10
                }}>{statusTypeJson[code]}</RadioButton>);
            }
        }
        return radioButtons;
    }

    render() {
        return (
            <RadioGroup onChange={this.handleStatusChange}>
                {this.getStatusList(StubStatus, this.props.currentStatus)}
            </RadioGroup>
        )
    }
}
export { UpdateStatus, StubStatus };
